#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int t;
	cin >> t;
	while (t--) {
		int x, hh, mm;
		char ch;
		cin >> x >> hh >> ch >> mm;
		mm += hh * 60;
		mm -= x;
		cout << mm / 60 << ":" << mm % 60 << endl;
//		cout << mm / 60 << ":" << setw(2) << setfill('0') << mm % 60 << endl;
	}
	return 0;
}
